﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Enter.Common;
using Enter.Entity;
using Enter.BizLogic;
using Enter.Config;

namespace Enter.Web.SystemAdmin.GoodClass
{
    public partial class importStockPropertyaspx : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ListCtrlHelper.BindEnumOnListControl(ddl_ProType, typeof(T106_GoodClassStockPropertyEntity.EnumProType));
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string code=this.txtcode.Text;
            string name=txtName.Text;
            save(code, name, "0");
            string[] vs = this.txtv.Text.Split('、');
            for (int i = 1; i <= vs.Length;i++ )
            {
                string zcode = GetCode(code, i);
                save(zcode, vs[i - 1], code);
            }
        }
        private string GetCode(string pcode, int num)
        {
            if (num < 10)
            {
                return pcode + "0" + num.ToString();
            }
            return pcode + num.ToString();
        }
        private void save(string code, string name, string ParentID)
        {
            T106_GoodClassStockPropertyEntity model = new T106_GoodClassStockPropertyEntity();
            T106_GoodClassStockPropertyBLLSub bll = new T106_GoodClassStockPropertyBLLSub();

            model.PNo = code;
            model.PName = name.Trim();

            
            model.ParentNO = ParentID;
            model.Status = EnumStatus.Valid;
            model.ProType = (T106_GoodClassStockPropertyEntity.EnumProType)byte.Parse(ddl_ProType.SelectedValue);
            bll.Save(model);
        }
    }
}